#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui>
#include "ui_MainWindow.h"
#include "ChatDialog.h"
#include "lib/bbs.h"
#include "lib/profile.h"
#include "SystrayIcon.h"

class bbsModel : public QAbstractItemModel {
    ///this MODEL maybe only to show the board list...?
    Q_OBJECT
    public:
	bbsModel(QObject *parent = 0);
	void addSource (BBS * bbs);
	void clear();
// 	bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
	QModelIndex index(int row, int column, const QModelIndex & parent) const;
	QModelIndex parent(const QModelIndex & child) const;
	int rowCount (const QModelIndex &parent) const;
	int columnCount (const QModelIndex &parent) const;
	QVariant data(const QModelIndex &index, int role) const;
    private:
	bool showAll(baseOnProfile * p) const;
	QList<BBS *> pool;
    public slots:
	void refresh(bool);
	
    public:
	static Board * index2Board(const QModelIndex & index);
	static Profile * index2Profile(const QModelIndex & index);
};

class MainWindow : public QMainWindow , public Ui::MainWindow
{
    Q_OBJECT
    public:
	MainWindow(QWidget * parent = 0);
	void closeEvent(QCloseEvent * event);

    public slots:
	void wakeup();
	void mainProcess();
	void on_actionStop_triggered();
	void on_actionClose_triggered();
	void on_actionQuit_triggered();
	void on_actionStart_triggered();
	void on_actionConfigure_triggered();
	void on_boardList_pressed(const QModelIndex & index );
	void on_boardList_activated(const QModelIndex & index);
	void systray_clicked(QSystemTrayIcon::ActivationReason reason );
	void updateStatusBar(int code = 0, QString explain = "");

	void on_actionAddFavorite_triggered();
	void on_actionShowList_triggered();

    private:
	void writeSettings();
	void readSettings();
	void createStatusBar();
	void createSystrayIcon();
	
    private:
	QList<Profile *> profiles;
	bbsModel * serverModel;
	QLabel * status;
};

#endif
